package demo_0526;

import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Test_0526 {
    public static void main(String[] args) throws SQLException {
        DataSource dataSource = new MysqlDataSource();
        ((MysqlDataSource) dataSource).setURL("jdbc:mysql://localhost:3306/wk?useSSL=false&serverTimezone=UTC");
        ((MysqlDataSource) dataSource).setUser("root");
        ((MysqlDataSource) dataSource).setPassword("123456");
        Connection connection = dataSource.getConnection();

        PreparedStatement preparedStatement = connection.prepareStatement("select * from student where name ='zhangsan'");
//        ResultSet resultSet =  preparedStatement.executeQuery();
//        while (resultSet.next()) {
//            System.out.println(resultSet.getString("name"));
//        }
//        int i = preparedStatement.executeUpdate();
//        System.out.println(i);

    }
}
